From "Got Questions"
The Gospel of John doesn’t explicitly name its author. At every mention of himself, the author states that he is “the disciple whom Jesus loved” (e.g., John 13:23). The author was an eyewitness to the events (see John 21:24), and, based on the fact that he was the disciple “leaning back against Jesus” at the Last Supper (John 13:25), he was likely one of Jesus’ inner circle, with Peter and James.
Peter is mentioned as separate from the author (John 21:20), and James was martyred early in the history of the church (Acts 12:2). That leaves John as the remaining disciple of the inner three and, thus, the author.
Apart from the internal clues, the early church uniformly affirmed the authorship of John. Church fathers like Irenaeus plainly spoke of John writing an epistle. Besides Irenaeus, writers like Tatian, Theophilus, Clement, and Tertullian attributed the fourth Gospel to John. John’s Gospel was more theological because he sought to address the theological issues faced by the newer generation of Christians as the apostolic age ended. False teachers had sprung up, questioning core beliefs of Christianity, such as Jesus’ humanity (see 1 John). As a counter, John began his Gospel by introducing the Word who was God and who became flesh (John 1:1, 14).
If John was not the author of his book, where is the testimony of the early church pastors claiming fraud? In fact, , they claimed John was the author:
The early church father Irenaeus (d. AD 200) claimed that John wrote the Fourth Gospel after he was released from prison on the island of Patmos (Rv 1:9) and lived in Ephesus. Irenaeus also wrote that he personally learned this information from the aged Polycarp, bishop of Smyrna (d. AD 155), who in turn was discipled by the apostle John.